-- FETCH_FOUNTAIN_BONUS

-- 抽取幸运喷泉奖励
-- @param user 玩家对象
return function(user)
    -- 获取随机种子
    local randSeed  = DungeonM.getRandSeed("FOUNTAIN_BONUS");
    local randSeed2 = DungeonM.getRandSeed("FOUNTAIN_BONUS");

    -- 随机抽取一种奖励（喷泉奖励配置在dungeon_fountain.csv中）
    local bonus = DungeonFountainM.fetchBonusBySeed(randSeed);
    local classId, amount, rank;
    local arr, arr2;
    local attrib = bonus["alias"];
    if "spell" == attrib then
        -- 卷轴
        -- 1到5级的比例为160,80,40,5,3
        arr = { { ["rank"] = 1, ["ratio"] = 160 }, { ["rank"] = 2, ["ratio"] = 80, }, 
                { ["rank"] = 3, ["ratio"] = 40 }, { ["rank"] = 4, ["ratio"] = 5, },
                { ["rank"] = 5, ["ratio"] = 3 }, 
              };
        arr2 = { 5, 4, 3, 2, 1};
        
        -- 抽取卷轴
        rank = fetchElemBySeed(arr, randSeed)["rank"];
        local scrollArr = ItemM.getScrollByRank(rank);
        classId = FormulaM.invoke("FETCH_BY_RAND", scrollArr, randSeed2);
        amount = arr2[rank];
        return { 1, classId, amount, };
    elseif "treasure" == attrib then
        -- 宝物
        -- 1到6级的比例为40,32,24,12,6,1
        arr = { { ["rank"] = 1, ["ratio"] = 40 }, { ["rank"] = 2, ["ratio"] = 32}, 
                { ["rank"] = 3, ["ratio"] = 24 }, { ["rank"] = 4, ["ratio"] = 12 },
                { ["rank"] = 5, ["ratio"] = 6  }, { ["rank"] = 6, ["ratio"] = 1 }, 
              };
        
        -- 抽取宝物
        rank = fetchElemBySeed(arr, randSeed)["rank"];
        local equipArr = ItemM.getEquipByRank(rank);
        classId = FormulaM.invoke("FETCH_BY_RAND", equipArr, randSeed2);
        return { 1, classId, 1 };
    elseif "attack" == attrib or "magic" == attrib then
        -- 攻击/魔力
        arr = { { ["amount"] = 1, ["ratio"] = 100, }, { ["amount"] = 2, ["ratio"] = 100, },
                { ["amount"] = 3, ["ratio"] = 100, }, };
        amount = fetchElemBySeed(arr, randSeed)["amount"];

        return { 2, attrib, amount };
    elseif "max_mp" == attrib or "max_hp" == attrib then
        -- 最大魔法值/最大生命值
        arr = { { ["amount"] = 10, ["ratio"] = 100, }, { ["amount"] = 20, ["ratio"] = 100, },
                { ["amount"] = 30, ["ratio"] = 100, }, };
        amount = fetchElemBySeed(arr, randSeed)["amount"];

        return { 2, attrib, amount };
    else
        -- 啥都没抽到，不应该，保护一下
        return { 2, "money", 1, };
    end
end